use crate::dto;
use crate::mq;
use std::sync::Arc;

pub struct Client {
    client: Arc<mq::client::Client>,
}

impl Client {
    pub fn new(client: Arc<mq::client::Client>) -> Self {
        Self { client }
    }

    pub async fn publish_setup_event(
        &self,
        node_id: &str,
        endpoint_id: &str,
    ) -> Result<(), anyhow::Error> {
        let event = dto::event::endpoint::srv6_config::new_setup_event(
            dto::event::endpoint::srv6_config::SetupEventPayload {
                endpoint_id: endpoint_id.to_string(),
            },
        );

        self.client.publish_json(mq::client::node::topic(node_id), &event).await
    }
}
